<f:view xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pm="http://primefaces.org/mobile" contentType="text/html">

	<f:event type="javax.faces.event.PreRenderViewEvent" listener="#{applicationBean.preRenderView}" />
	
	<f:metadata>
		<f:viewParam name="cinema" value="#{parameter.cinema}" />
		<f:viewParam name="films" value="#{parameter.films}" />
		<f:viewParam name="score" value="#{parameter.score}" />
	</f:metadata>
	
	<pm:page title="Films">
		<pm:view id="main">
			<pm:header title="Films" />
			<pm:content>
				<h:form id="filmsForm">
                    <p:dataList  id="filmList" value="#{filmController.films}" var="f">
                        <p:column>
                         	<p:graphicImage value="#{f.locandina}" />
                         	<h1>
	                            <p:commandLink value="#{f.titolo}" action="pm:filmDetail" update=":filmDetailForm" >
  									<f:setPropertyActionListener value="#{f}" target="#{filmController.selectedFilm}" />
	                            </p:commandLink>
                            </h1>
                            <p><h:outputText value="#{f.score_label} #{f.score}" /></p>
                        </p:column>
                    </p:dataList>
	        	</h:form>
			</pm:content>
    	</pm:view>
		
		<pm:view id="filmDetail">
        	<pm:header title="Film Details">
                <f:facet name="left"><p:button value="Back" icon="back" href="#main?reverse=true"/></f:facet>
       	    </pm:header>
			<pm:content>
	            <h:form id="filmDetailForm">
           			<h2><h:outputText value="#{filmController.selectedFilm.titolo}" /></h2>
                   	<p><h:outputText value="Indice Gradimento: #{filmController.selectedFilm.ind_gradimento}" /></p>
                   	<p><h:outputText value="Descrizione: #{filmController.selectedFilm.descrizione}" /></p>
                    <p:panel header="Trama" collapsed="true">
                    	<p><h:outputText value="#{filmController.selectedFilm.trama}" /></p>
                    </p:panel>
                    <p:panel header="Proiezioni" collapsed="true">
	                    <p:dataList  id="proiezioni" value="#{filmController.selectedFilm.proiezioni}" var="p">
		                   	<p><h:outputText value="Ora: #{p.ora} Prezzo : #{p.prezzo} TreD : #{p.treD}" /></p>
                    	</p:dataList>
                    </p:panel>
                    <p:panel header="Regista e Attori" collapsed="true">
	                    <p:dataList  id="persone" value="#{filmController.selectedFilm.persone}" var="p">
		                   	<p><h:outputText value="#{p.nome_cognome} (#{p.ruolo})" /></p>
                    	</p:dataList>
                    </p:panel>
				</h:form>
			</pm:content>
        </pm:view>
	</pm:page>
</f:view>